// 导入定义仓库的方法
import { defineStore } from 'pinia';

// 导入响应式和计算
import { ref } from 'vue'
const  userInfoStore = defineStore("userInfoStore",() => {
		// accessToken
		const accessToken=ref('');
		// accessToken Set
		const setToken = (token:string) => {
			accessToken.value = token;
		}
		const offices = ref([])
		const setOffices = (list: [])=>{
			offices.value = list
		}
		const products = ref([])
		const setProducts = (list: [])=>{
			products.value = list
		}
		const userInfo = ref({})
		const setUserInfo = (obj: object)=>{
			userInfo.value = obj
		}
		return {accessToken, setToken, offices, setOffices, products, setProducts, userInfo, setUserInfo}
	},
  // TODO: 持久化
  {
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key)
        },
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
      },
    },
	}
) 

export default userInfoStore;    			   
